import numpy as np

# 分析EPS2文件结构
file_path = 'EPS2data/18/66BC75C6.012'
with open(file_path, 'rb') as f:
    header = f.read(16)
    data_bytes = f.read()
    
# 尝试不同的数据类型
data_int32 = np.frombuffer(data_bytes, dtype=np.int32)
data_int16 = np.frombuffer(data_bytes, dtype=np.int16)
data_float32 = np.frombuffer(data_bytes, dtype=np.float32)

print(f"Header: {header}")
print(f"Data length (int32): {len(data_int32)}")
print(f"Data length (int16): {len(data_int16)}")
print(f"Data length (float32): {len(data_float32)}")

# 检查是否能被3整除
print(f"Data length mod 3 (int32): {len(data_int32) % 3}")
print(f"Data length mod 3 (int16): {len(data_int16) % 3}")
print(f"Data length mod 3 (float32): {len(data_float32) % 3}")

# 尝试找到三分量结构
print("\nFirst 30 values (int32):")
for i in range(0, min(30, len(data_int32)), 3):
    print(f"{i}: {data_int32[i:i+3]}")

print("\nFirst 30 values (int16):")
for i in range(0, min(30, len(data_int16)), 3):
    print(f"{i}: {data_int16[i:i+3]}")

# 尝试去除可能的头部/尾部信息
# 对于int32数据，长度是545294，mod 3 = 2，可能需要去除2个值
adjusted_int32 = data_int32[:-2] if len(data_int32) % 3 == 2 else data_int32
print(f"\nAdjusted int32 data length: {len(adjusted_int32)}")
print(f"Adjusted int32 data length mod 3: {len(adjusted_int32) % 3}")

# 对于int16数据，长度是1090588，mod 3 = 1，可能需要去除1个值
adjusted_int16 = data_int16[:-1] if len(data_int16) % 3 == 1 else data_int16
print(f"Adjusted int16 data length: {len(adjusted_int16)}")
print(f"Adjusted int16 data length mod 3: {len(adjusted_int16) % 3}")

# 检查调整后的数据
print("\nAdjusted int32 first 30 values:")
for i in range(0, min(30, len(adjusted_int32)), 3):
    print(f"{i}: {adjusted_int32[i:i+3]}")

print("\nAdjusted int16 first 30 values:")
for i in range(0, min(30, len(adjusted_int16)), 3):
    print(f"{i}: {adjusted_int16[i:i+3]}")